import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:customer_log_app/global/console.dart';
import 'package:customer_log_app/global/sqlite_helper.dart';

class LangProvider extends ChangeNotifier {
  String _lang = '';
  get lang => _lang;

  late List _translations = [];
  get translations => _translations;

  LangProvider() {
    _lang = lang;
  }

  void change(String v) {
    _lang = v;
    notifyListeners();
  }

  void getTrans() async {
    log('getTrans');
    try {
      if (Platform.isAndroid || Platform.isFuchsia || Platform.isIOS) {
        log('get translations from db');
        SqliteHelper sqlHelper = SqliteHelper();
        String sql = "select * from translation ";
        var list = await sqlHelper.getData(sql);
        log(list);
      }
    } catch (e) {
      log(e);
    }

    _translations = [
      {'key': '', 'value': ''}
    ];
    _lang = 'test';
    notifyListeners();
  }
}
